<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/WEB-INF/struts-tags.tld"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>欢迎访问产品运营互动中心！</title>

		<script src="<s:url value="/script/jquery_last.js"/>"
			type="text/javascript"></script>
		<script src="<s:url value="/script/formValidator.js"/>"
			type="text/javascript" charset="UTF-8"></script>
		<script src="<s:url value="/script/formValidatorRegex.js"/>"
			type="text/javascript" charset="UTF-8"></script>
		<script language="javascript"
			src="<s:url value="/script/DateTimeMask.js"/>" type="text/javascript"></script>
		<script type="text/javascript"
			src="<s:url value="/script/selfResize.js"/>"></script>
		<script type="text/javascript">
$(document).ready(function(){
	$.formValidator.initConfig({autotip:true,onerror:function(msg){alert(msg)}});
	$("input:text[name='product.name']").formValidator({tipid:"producttip",onshow:"产品名称"}).inputValidator({min:1,onerror:"产品名称不能为空,请填写产品名称。",empty:{leftempty:false,rightempty:false,emptyerror:"产品名称左右不能有空值"}});
	$("textarea[name='product.briefIntroduction']").formValidator({tipid:"briefIntroductiontip",onshow:"请输入资料内容"}).inputValidator({max:3000,onerror:"您输入的描述长度不能大于300字。"});
	$("textarea[name='propertyValue']").formValidator({tipid:"propertyValuetip",onshow:"请输入产品属性内容"}).inputValidator({max:4000,onerror:"您输入的描述长度不能大于4000字。"});
});
function show(url){
	window.open(url);
}
function initLoad(){
	f_iframeResize();
}
function initData(){
	initLoad();
}
window.onload = initData;
</script>

		<link rel="stylesheet" href="<s:url value="/css/style_new.css"/>">
		<link rel="stylesheet" href="<s:url value="/css/validator.css"/>">

	</head>
	<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
		<table width="730" border="0" cellspacing="0" cellpadding="0"
			align="center">
			<tr>
				<td>
					<table width="98%" height="400" border="0" cellspacing="0"
						cellpadding="0" align="center" bgcolor="#FFFFFF">
						<tr>
							<td valign="top">
								<s:form id="form1" action="/business/product/su_saveProduct.action"
									namespace="/business/catalog" enctype="multipart/form-data"
									onsubmit="return ($.formValidator.pageIsValid('1')&&save());"
									method="post">
									<input type="hidden" name="product.id" value="${product.id}">
									<input type="hidden" name="addInfos">
									<input type="hidden" name="addValues">
									<input type="hidden" name="product.begin" value="${product.begin}">
									<input type="hidden" name="product.end" value="${product.end}">
									<input type="hidden" name="product.reqCode" value="${product.reqCode}">
									<input type="hidden" name="product.isClient" value="${product.isClient}">
									<input type="hidden" name="product.procinstId" value="${product.procinstId}">
									<table width=98% align="center" border="0" cellspacing="0"
										cellpadding="0">
										<tr>
											<td height="5">
												<table width="100%" border="0" cellspacing="0" cellpadding="0">
													<tr>
														<td width="5" height="5"><img src="<s:url value="/images/cphdzx_tab1.gif"/>" width="5" height="5" /></td>
														<td class="tdborderup"><img src="<s:url value="/images/spacer.gif"/>" width="1" height="1" /></td>
														<td width="5"><img src="<s:url value="/images/cphdzx_tab2.gif"/>" width="5" height="5" /></td>
													</tr>
												</table>
											</td>
										</tr>
										<tr>
											<td class=tdborderleftright>
												<TABLE width="98%" cellSpacing=1 cellPadding=0
													align="center">
													<TR height=30>
														<TD align=left width="10%">
															<input type="Submit" name="Submit" id="Submit" value="保 存">
															<input type="button" value="返 回"
																onClick="pageBack()">
															<input type="button" value="添加产品属性"
																onClick="selectDict()">
															<s:if test="product.id!=''">
																<input type="button" name="new" value="继续新增"
																	onClick="addContinue()">
															</s:if>
														</TD>
													</TR>
												</table>
												<s:if test="#returnMsg==null">

												</s:if>
												<s:else>
													<TABLE width="98%" cellSpacing=1 cellPadding=0
														align="center">
														<TR height=30>
															<TD align=left width="10%">
																<font color="red">${returnMsg}</font>
															</TD>
														</TR>
													</table>
												</s:else>
												<table id="propertyTable" width="98%" border="0"
													cellspacing="0" cellpadding="7" align="center"
													class=tablecolor2>
													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right">
																<font color="red">*</font>产品名称：
															</div>
														</td>
														<td width="81%">
															<s:textfield name="product.name" theme="css_xhtml"
																size="75" />
															<div id="producttip" style="width:20px"></div>
														</td>
													</tr>
													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right">
																访问地址：
															</div>
														</td>
														<td width="81%">
															<s:textfield name="product.linkUrl" theme="css_xhtml"
																size="75" />
														</td>
													</tr>
													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right">
																产品简介：
															</div>
														</td>
														<td width="81%">
															<s:textarea rows="3" cols="60"
																name="product.briefIntroduction" theme="css_xhtml"></s:textarea>
															<div id="briefIntroductiontip" style="width:20px"></div>
														</td>
													</tr>
													<input type="hidden" name="product.creator"
														value="${product.creator}">

													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right">
																功能点描述：
															</div>
														</td>
														<td width="81%">
															<s:textarea name="product.description" cols="60" rows="3"
																theme="css_xhtml"></s:textarea>
														</td>
													</tr>
													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right">
																<font color="red">*</font>主要负责人：
															</div>
														</td>
														<td width="81%">
															<input type="hidden" name="mainPersons" value="${mainPersons}">
															<input type="text" id="mainPersonNames" name="mainPersonNames" readonly value="${mainPersonNames}">
															<input type="button" name="selType" value="选择人员"
																onClick="selectMainPerson()" />
														</td>
													</tr>
													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right">
																其它负责人：
															</div>
														</td>
														<td width="81%">
															<input type="hidden" name="persons" value="${persons}">
															<input type="text" name="personNames" readonly
																value="${personNames}">
															<input type="button" name="selType" value="选择人员"
																onClick="selectPerson()" />
														</td>
													</tr>
													
													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right">
																所属集团目录：
															</div>
														</td>
														<td width="81%">
				                      <input type="hidden" id="sortId1" name="productSortId" value="${jtProductSort.id}">
				                      <input type="text" id="sortName1" name="productSortName" readonly value="${jtProductSort.name}" size="55">
									  					<input type="button" name="selType1" value="选择集团目录" onClick="showTypeDialog(1)"/>
														</td>
													</tr>
													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right">
																所属福建省目录：
															</div>
														</td>
														<td width="81%">
				                      <input type="hidden" id="sortId2" name="productSortId" value="${shProductSort.id}">
				                      <input type="text" id="sortName2" name="productSortName" readonly value="${shProductSort.name}" size="55">
									  					<input type="button" name="selType2" value="选择福建省目录" onClick="showTypeDialog(2)"/>
														</td>
													</tr>
													
													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right">
																是否新产品：
															</div>
														</td>
														<td width="81%">
															<select name="product.isNew" style="width:155px">
																<option value="1">
																	是
																</option>
																<option value="0">
																	否
																</option>
															</select>
														</td>
													</tr>

													<tr>
														<td width="19%" bgcolor="D6E3FA">
															<div align="right" class="STYLE2">
																产品图片：
															</div>
														</td>
														<td width="81%">
															<table width="98%" border="0" class=tablecolor2>
																<tr>
																	<td width="" align="center" bgcolor="D6E3FA">
																		附件名称
																	</td>
																	<td width="50" align="center" bgcolor="D6E3FA">
																		删除
																	</td>
																</tr>
																<s:iterator id="attach" value="attachs">
																	<input type="hidden" name="attachIDs"
																		value="<s:property value="id" />" />
																	<tr>
																		<td>
																			<a
																				href="<s:url value="/common/showFile.action?attach.id="/><s:property value="id" />"
																				target="_blank"> <s:property value="fullName" />
																			</a>
																		</td>
																		<td align="center">
																			<input type="checkbox" name="delIDs"
																				value="<s:property value="id" />">
																		</td>
																	</tr>
																</s:iterator>
															</table>
															<br />
															<table width="98%" border="0" class=tablecolor2>
																<tr>
																	<td width="98%" colspan="2">
																		&nbsp;
																		<font color="red">注：只限于上传img、jpg、gif等图片格式文件，大小限制为10M.</font>
																	</td>
																</tr>
																<tr>
																	<td width="10px">
																		&nbsp;
																	</td>
																	<td align="left">
																		<input type="file" name="upload" size="40" />
																	</td>
																</tr>
																<tr>
																	<td>
																		&nbsp;
																	</td>
																	<td>
																		<input type="file" name="upload" size="40" />
																	</td>
																</tr>
																<tr>
																	<td>
																		&nbsp;
																	</td>
																	<td>
																		<input type="file" name="upload" size="40" />
																	</td>
																</tr>
															</table>
														</td>
													</tr>

													<s:iterator id="info" value="product.productInfos">

														<tr>
															<td align="right" bgcolor="D6E3FA">
																<s:property value="productPropertyName" />
																：
																<input type="hidden" name="infoIds"
																	value="<s:property value="productProperty" />" />
															</td>
															<td>
																<s:textarea name="propertyValue" theme="css_xhtml"
																	cols="60" rows="3" />
																<div id="propertyValuetip" style="width:auto"></div>
															</td>

														</tr>
													</s:iterator>
												</table>
											</td>
										</tr>
										<tr>
											<td class=tdborderleftright>
												<TABLE width="98%" cellSpacing=1 cellPadding=0
													align="center">
													<TR height=30>
														<TD align=left width="10%">
															<input type="Submit" name="Submit1" id="Submit1" value="保 存">
															<input type="button" value="返 回"
																onClick="pageBack()">
															<input type="button" value="添加产品属性"
																onClick="selectDict()">
															<s:if test="product.id!=''">
																<input type="button" name="new" value="继续新增"
																	onClick="addContinue()">
															</s:if>
														</TD>
													</TR>
												</table>
											</td>
										</tr>
										<tr>
											<td height="5">
												<table width="100%" border="0" cellspacing="0" cellpadding="0">
													<tr>
														<td width="5" height="5"><img src="<s:url value="/images/cphdzx_tab3.gif"/>" width="5" height="5" /></td>
														<td class="tdborderbottom"><img src="<s:url value="/images/spacer.gif"/>" width="1" height="1" /></td>
														<td width="5"><img src="<s:url value="/images/cphdzx_tab4.gif"/>" width="5" height="5" /></td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
							</td>
						</tr>
					</table>
					</s:form>
					<!--
				   -->
					<form action="su_editProduct.action"  name="form2"  id="form2"  method="post"   enctype="multipart/form-data" >

				   </form>
	</body>
</html>
<script>
if("${product.isNew}"==0){
	document.forms[0]["product.isNew"].options[1].selected=true;
}
function showTypeDialog(flag){
	var url='<s:url value="/xtreecheckbox/selectProductSort.jsp?type=radio&sortType=1&date=" escapeAmp="false"/>'+'<%=System.currentTimeMillis()%>';
	if(flag==2){
		url='<s:url value="/xtreecheckbox/selectProductSort.jsp?type=radio&sortType=2&date=" escapeAmp="false"/>'+'<%=System.currentTimeMillis()%>';
		//url="<s:url value='/' escapeAmp='false'/>"+"/xtreecheckbox/selectProductSort.jsp?type=radio&sortType=2&date=<%=System.currentTimeMillis()%>";
	}
    //alert(url);
	var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:450px;dialogHeight:600px;scroll:yes;");
	if(returnData){
		if(flag==2){
			document.getElementById("sortName2").value=returnData[1];
			document.getElementById("sortId2").value=returnData[0];
		}else{
			document.getElementById("sortName1").value=returnData[1];
			document.getElementById("sortId1").value=returnData[0];
		}
	}
}

function save(){
	var propertyValues=document.getElementsByName("propertyValue");
	var infoIds=document.getElementsByName("infoIds");
	form1.addInfos.value="";
	form1.addValues.value="";
	var spaceNum=0;
	var mainPersonName=document.getElementById("mainPersonNames");
	if(mainPersonName){
		if(mainPersonName.value.replace(" ","")==""){
			alert("主要负责人不能为空，请选择主要负责人！");
			return false;
		}
	}
	for(i=0;i<propertyValues.length;i++){
	    if(propertyValues[i].value!=""){
			form1.addInfos.value+=infoIds[i].value+",";
			form1.addValues.value+=propertyValues[i].value+",";
		}else{
			spaceNum++;
		}
	}
	if(spaceNum>0){
		if(!confirm("为空的动态属性会被系统删除，是否继续保存？")){
			return false;
		}
	}
	form1.addInfos.value=form1.addInfos.value.substring(0,form1.addInfos.value.length-1);
	form1.addValues.value=form1.addValues.value.substring(0,form1.addValues.value.length-1);
	//$("#form1").submit();
	if (!checkFile()) return false;
	b_setDisable(document.getElementById("Submit"));
	b_setDisable(document.getElementById("Submit1"));
	
	return true;
}

function checkFile()   
{   
  var obj=document.all["upload"];
  var s=true;
  if (obj){
	  var len=obj.length;
	  if (len){
		  if (len==1){
			  f=obj.value;
			  if (f!=""){
				  s=checkFileType(f);	
				  if (!s) {
					  alert("上传文件是限制文件类型文件");
					  obj[i].focus();
					  return false;	
				  }	
			  }
		  }else if (len>1){
			  for (i=0;i<len;i++){
				  f=obj[i].value;
				  if (f!=""){
					  s=checkFileType(f);	
					  if (!s) {
						  alert("上传文件是限制文件类型文件");
						  obj[i].focus();
						  return false;	
					  }		
				  }  
			  }
		  }
	  }
  }
  return s;  
} 

function checkFileType(sfile){
	  sfile=sfile.substr(sfile.lastIndexOf(".")+1)   
	  if(sfile!="img" && sfile!="jpg" && sfile!="gif")   
	  {    
	  	return false;   
	  } 
	  return true; 
}

function selectDict(){
    var url='<s:url value="/business/productDict/listProductDictSelect.action"/>';
    //window.prompt("",url);
	window.showModalDialog(url, window,"status:no;dialogWidth:800px;dialogHeight:550px;scroll:yes;");
	initLoad();
	window.parent.changeScroll();
}

function selectMainPerson(){
    var url="<s:url value='/' escapeAmp='false'/>"+"organ/toOrganTree.action?type=&path=toPersonTree&module=radio&date=<%=System.currentTimeMillis()%>";	 var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:650px;dialogHeight:600px;scroll:yes;");
	 if(returnData){
	 	document.forms[0]["mainPersonNames"].value=returnData[1];
	 	document.forms[0]["mainPersons"].value=returnData[0];
	 }
}
function selectPerson(){
    var url="<s:url value='/' escapeAmp='false'/>"+"organ/toOrganTree.action?type=&path=toPersonTree&module=checkbox&date=<%=System.currentTimeMillis()%>";
	 var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:650px;dialogHeight:600px;scroll:yes;");
	 if(returnData){
	 	document.forms[0]["personNames"].value=returnData[1];
	 	document.forms[0]["persons"].value=returnData[0];
	 }
}
function pageBack(){
	var sortId="${productSort.id}";
	if(sortId&&sortId!=""){
		window.parent.checkSort("${productSort.id}");
	}else{
		window.history.back();
	}
}
function addContinue(){
	document.form2.submit();
}
</script>
